<?php
//echo "pase DENTRO GRID INTERNACION"; //DEBUG FD

if(!isset($_SESSION['consultorio'])){
session_start();
}
//echo "pase";    //DEBUG FD
require_once('jq-configin.php');
//require_once ('/Applications/MAMP/htdocs/HS/jqSuitePHP_4_1_2_2/jq-config.php');
// include the jqGrid Class

require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");


// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query

// Write the SQL Query

$grid->SelectCommand = "SELECT camas.idCama,sectorconsultorio.descSectorConsultorio,camas.NumeroCama,paciente.NumDoc,
paciente.Apellido, camas_x_diagnosticointernacion.fechaCamaDiagnosticoInternacion, diagnosticointernacion.descDiagnosticoInternacion 
FROM camas 
INNER JOIN sectorconsultorio  ON camas.Estado='Ocupada' AND sectorconsultorio.idConsultorio='".$_SESSION['consultorio']."' 
AND sectorconsultorio.idSectorConsultorio=camas.idSectorConsultorio
INNER JOIN paciente  ON camas.idPaciente=paciente.idpaciente 
INNER JOIN camas_x_diagnosticointernacion ON camas_x_diagnosticointernacion.idCama=camas.idCama
INNER JOIN diagnosticointernacion ON diagnosticointernacion.idDiagnosticoInternacion=camas_x_diagnosticointernacion.idDiagnosticoInternacion";


$grid->table = 'camas'; 
//echo $grid->SelectCommand ;
// Set the table to where you update the data
//$grid->table = 'paciente';
// Set output format to json
$grid->dataType = 'json';
// Let the grid create the model

$grid->setColModel();

$grid->setUrl("Internacion/Grid/gridinternacion.php");

// Set the url from where we obtain the data
// Set the url from where we obtain the data
// Set some grid options
$grid->setGridOptions(array(
        "caption"=>"Pacientes Internados", 
        "width"=>570,
        "height"=>100,  
    "rowNum"=>20,
    "rowList"=>array(20,40,60),

    "shrinkToFit"=>false,
    "sortname"=>"idCama"
    
));

// Set the table to where you add the data 

$grid->setColProperty('idCama', array("label"=>"ID","editable"=>false, "width"=>30));
$grid->setColProperty('descSectorConsultorio', array("label"=>"Sector", "width"=>100));
$grid->setColProperty('NumeroCama', array("label"=>"Cama", "width"=>40));
$grid->setColProperty('Apellido', array("label"=>"Apellido", "width"=>100));
$grid->setColProperty('NumDoc', array("label"=>"Documento", "width"=>80));
$grid->setColProperty('fechaCamaDiagnosticoInternacion', array("label"=>"Fecha", "width"=>80));
$grid->setColProperty('descDiagnosticoInternacion', array("label"=>"Diagn&oacute;stico", "width"=>140));





$grid->toolbarfilter = true; 
// Enable navigator

$grid->navigator = true;
// Enable only editing
//$grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>false));

$grid->setNavOptions('navigator', array("excel"=>true,"add"=>false,"edit"=>true,"del"=>true,"view"=>true, "search"=>true));

// Enjoy
$grid->renderGrid('#gridinternacion','#pagerinternacion',true, null, null, true,true);
// we set the select for ship city 

//$grid->setSelect("ShipCity", "SELECT DISTINCT ShipCity, ShipCity AS CityName FROM orders ORDER BY 2", false, false, true, array(""=>"All"))

$conn = null;

?> 
 


